﻿using SDDP;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DotNetStar.TheKing.Domain
{
    /// <summary>
    /// 用户积分记录
    /// </summary>
    [Table("UserPointHistories")]
    public class UserPointHistory : IEntity<Guid>
    {
        [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public Guid Id { get;internal set; } = Guid.NewGuid();

        /// <summary>
        /// 积分策略主键
        /// </summary>
        [Required,StringLength(20)]
        public string PointStrategyId { get; set; }

        /// <summary>
        /// 经验值
        /// </summary>
        public int Exp { get; set; }
        /// <summary>
        /// 交易积分
        /// </summary>
        public int TradingPoints { get; set; }

        [StringLength(100)]
        public string Remark { get; set; }

        /// <summary>
        /// 记录时间
        /// </summary>
        public DateTime CreatedTime { get;internal set; } = DateTime.Now;

        public long UserId { get; set; }

        public static string GetUserPointCacheKey(long userId)=> $"user-point-{userId}";
        

    }
}
